$(function(){ $(window).on('load',function(){ var ser_btn = $("#ser_btn"),//搜索栏按钮 ser_text = $(".ser_text"),//搜索栏 ser_flag = false,//搜索栏展开状态 ser_speed = 400,//搜索栏移动速度 head_h = $(".head_h"),//顶部高度 head = $(".head"),//导航栏, r_speed = 500,//侧边栏移动速度 r_menu = $("#menu_btn"),//侧边栏按钮 share_a = $("#fta1"),//底部下属连接 right_side = $(".right_side"),//侧边栏 r_flag = false,//侧边栏展开状态 r_width = right_side.width(),//侧边栏偏移量 logo_area = $(".logo_area"),//logo区域 right_area = $(".right_area"),//导航右侧按钮区域 mask = $(".mask"), color_rbg = $("#color_rbg"),//右色块 backtop = $("#backtop"),//返回顶部 wint = 0,//顶部位置 body = $("body"), top_area = $(".top_area"),//二级标题栏 top_pos = $(".top_area").css("position");//二级标题栏定位属性 bodyfix();//修正body宽度 ser_toggle();//搜索区域开关 r_side();//右侧栏 btop();//返回顶部 secfixed();//固定顶部 //修正body宽度 function bodyfix(){ $("body").width($(window).width()); $(window).resize(function(){ $("body").width($(window).width()); }); } function ser_toggle(){ ser_btn.on('click',function(){ if(ser_flag == false){ //打开搜索栏 ser_flag = true; head_h.animate({height:'120px'},ser_speed,'easeInOutExpo'); ser_text.animate({top:'35px'},ser_speed,'easeInOutExpo'); if(top_pos=="fixed"){ top_area.animate({top:'120px'},ser_speed,'easeInOutExpo'); body.animate({paddingTop:'175px'},ser_speed,'easeInOutExpo'); } }else{ //关闭搜索栏 ser_flag = false; head_h.animate({height:'82px'},ser_speed,'easeInOutExpo'); ser_text.animate({top:'-35px'},ser_speed,'easeInOutExpo'); if(top_pos=="fixed"){ top_area.animate({top:'82px'},ser_speed,'easeInOutExpo'); body.animate({paddingTop:'137px'},ser_speed,'easeInOutExpo'); }else{ body.animate({paddingTop:'82px'},ser_speed,'easeInOutExpo'); } } }); } function r_side(){ //right_side.height(document.body.offsetHeight);//设置侧边栏高度 right_side.height($(window).height());//设置侧边栏高度 $(window).resize(function(){ //right_side.height(document.body.offsetHeight);//设置侧边栏高度 right_side.height($(window).height());//设置侧边栏高度 }); //侧边栏按钮点击事件 r_menu.on('click',function(){ if(r_flag == false){ //打开侧边栏 r_flag = true; w_move_left(); //显示点击区域 mask.show(); }else{ //关闭侧边栏 r_flag = false; w_move_right(); } }); //底部下属连接点击事件 share_a.on('click',function(){ if(r_flag == false){ //打开侧边栏 r_flag = true; w_move_left(); //显示点击区域 mask.show(); }else{ //关闭侧边栏 r_flag = false; w_move_right(); } return false; }); //点击其他区域关闭侧边栏 mask.on('click',function(){ //隐藏点击区域 mask.hide(); //关闭侧边栏 r_flag = false; w_move_right(); }); //整体左偏移 function w_move_left(){ $("body").animate({marginLeft: - r_width},r_speed,'easeInOutExpo'); color_rbg.animate({right: '10px'},r_speed,'easeInOutExpo'); right_side.animate({right:'0'},r_speed,'easeInOutExpo'); head.animate({left: - r_width },r_speed,'easeInOutExpo'); backtop.animate({right: '+=' + r_width },r_speed,'easeInOutExpo'); if(top_pos == "fixed"){//判断移动二级标题栏目 top_area.animate({left: - r_width },r_speed,'easeInOutExpo'); } } //整体恢复 function w_move_right(){ $("body").stop().animate({marginLeft:'0'},r_speed,'easeInOutExpo'); color_rbg.animate({right: '0px'},r_speed,'easeInOutExpo'); right_side.animate({right: - r_width},r_speed,'easeInOutExpo'); head.animate({left: '0' },r_speed,'easeInOutExpo'); backtop.animate({right: '-=' + r_width },r_speed,'easeInOutExpo'); if(top_pos == "fixed"){//判断移动二级标题栏目 top_area.animate({left:'0'},r_speed,'easeInOutExpo'); } } } //固定二级标题 function secfixed(){ fixed(); $(window).on('scroll',function(){ fixed(); }); function fixed(){ wint = $(window).scrollTop(); if(r_flag == false){ //右侧栏为关闭状态时 if(ser_flag == true){ //搜索栏为打开状态时 top_pos = $(".top_area").css("position"); if(wint >= 120){ //页面位置大于120px时 top_area.css({position:'fixed',top:'120px',left:'0',borderTop:'1px solid #e2e5e6',zIndex:'3'}); $("body").css({paddingTop:'175px'}); }else{ //页面位置不足120px时 top_area.css({position:'static',top:'0',left:'0',borderTop:'none'}); $("body").css({paddingTop:'120px'}); } }else{//搜索栏为关闭状态时 top_pos = $(".top_area").css("position"); if(wint >= 102){ //页面位置大于120px时 top_area.css({position:'fixed',top:'82px',left:'0',borderTop:'1px solid #e2e5e6',zIndex:'3'}); $("body").css({paddingTop:'137px'}); }else{ //页面位置不足120px时 top_area.css({position:'static',top:'0',left:'0',borderTop:'none'}); $("body").css({paddingTop:'82px'}); } } }else{ //右侧栏为打开状态时 if(ser_flag == true){ //搜索栏为打开状态时 top_pos = $(".top_area").css("position"); if(wint >= 120){ //页面位置大于120px时 top_area.css({position:'fixed',top:'120px',left:-r_width,borderTop:'1px solid #e2e5e6',zIndex:'3'}); $("body").css({paddingTop:'140px'}); }else{ //页面位置不足120px时 top_area.css({position:'static',top:'0',left:-r_width,borderTop:'none'}); $("body").css({paddingTop:'120px'}); } }else{ //搜索栏为关闭状态时 top_pos = $(".top_area").css("position"); if(wint >= 102){ //页面位置大于120px时 top_area.css({position:'fixed',top:'82px',left:-r_width,borderTop:'1px solid #e2e5e6',zIndex:'3'}); $("body").css({paddingTop:'137px'}); }else{ //页面位置不足120px时 top_area.css({position:'static',top:'0',left:-r_width,borderTop:'none'}); $("body").css({paddingTop:'82px'}); } } } } } //当前位置样式处理 $(".currentpage").find("span").last().css({background:'none'}); $(".currentpage").find("span").last().children().css({color:'#ff6000'}); //返回顶部 function btop(){ $(window).on('scroll',function(){ wint = $(window).scrollTop(); if(wint <= 500){ backtop.fadeOut(300); } if(wint > 500){ backtop.fadeIn(300); } }); backtop.on('click',function(){ $("html,body").stop(false,true).animate({"scrollTop":0},1200,'easeInOutExpo'); return false; }); } //底部oa function oashow(){ $(".boa").mouseenter(function(){ $(".boa").addClass("on"); $(".boa_box").stop(false,true).animate({width:'190px'},400); }); $(".footer .top").mouseleave(function(){ $(".boa").removeClass("on"); $(".boa_box").stop(false,true).animate({width:'0'},400); }); } oashow(); }); });